﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <el-form ref="formRefSpcAnalysis" :model="stateSpcAnalysis.vmModel" label-width="100px">
    <div style="margin-bottom:10px;">{{$t('message.autotrans.SysBatchEditConfirm')}}</div>
    <el-row>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Code_FormItem" prop="LinkedVM.Code" :label="$t('message.autotrans._Model_SpcAnalysis_Code')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_SpcAnalysis_Code')}), trigger: 'blur' }]" >
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.Code" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Desc_FormItem" prop="LinkedVM.Desc" :label="$t('message.autotrans._Model_SpcAnalysis_Desc')">
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.Desc" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ChartType_FormItem" prop="LinkedVM.ChartType" :label="$t('message.autotrans._Model_SpcAnalysis_ChartType')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_SpcAnalysis_ChartType')}), trigger: 'blur' }]" >
          <el-select v-model="stateSpcAnalysis.vmModel.LinkedVM.ChartType" clearable>
             <el-option key="C" value="C" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_C')"></el-option>
             <el-option key="C_U" value="C_U" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_C_U')"></el-option>
             <el-option key="NP_P" value="NP_P" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_NP_P')"></el-option>
             <el-option key="Xbar_R_Xbar_S" value="Xbar_R_Xbar_S" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_Xbar_R_Xbar_S')"></el-option>
             <el-option key="U" value="U" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_U')"></el-option>
             <el-option key="NP" value="NP" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_NP')"></el-option>
             <el-option key="P" value="P" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_P')"></el-option>
             <el-option key="I_MR" value="I_MR" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_I_MR')"></el-option>
             <el-option key="Xbar_S" value="Xbar_S" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_Xbar_S')"></el-option>
             <el-option key="Xbar_R" value="Xbar_R" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_Xbar_R')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ProductId_FormItem" prop="LinkedVM.ProductId" :label="$t('message.autotrans._Model_SpcAnalysis_ProductId')">
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.ProductId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ProductName_FormItem" prop="LinkedVM.ProductName" :label="$t('message.autotrans._Model_SpcAnalysis_ProductName')">
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.ProductName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OpId_FormItem" prop="LinkedVM.OpId" :label="$t('message.autotrans._Model_SpcAnalysis_OpId')">
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.OpId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OpName_FormItem" prop="LinkedVM.OpName" :label="$t('message.autotrans._Model_SpcAnalysis_OpName')">
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.OpName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ChartName_FormItem" prop="LinkedVM.ChartName" :label="$t('message.autotrans._Model_SpcAnalysis_ChartName')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_SpcAnalysis_ChartName')}), trigger: 'blur' }]" >
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.ChartName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_DataName_FormItem" prop="LinkedVM.DataName" :label="$t('message.autotrans._Model_SpcAnalysis_DataName')">
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.DataName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_DataTag_FormItem" prop="LinkedVM.DataTag" :label="$t('message.autotrans._Model_SpcAnalysis_DataTag')">
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.DataTag" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_SimpleQty_FormItem" prop="LinkedVM.SimpleQty" :label="$t('message.autotrans._Model_SpcAnalysis_SimpleQty')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_SpcAnalysis_SimpleQty')}), trigger: 'blur' }]" >
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.SimpleQty" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_UCL_FormItem" prop="LinkedVM.UCL" :label="$t('message.autotrans._Model_SpcAnalysis_UCL')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_SpcAnalysis_UCL')}), trigger: 'blur' }]" >
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.UCL" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_CL_FormItem" prop="LinkedVM.CL" :label="$t('message.autotrans._Model_SpcAnalysis_CL')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_SpcAnalysis_CL')}), trigger: 'blur' }]" >
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.CL" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_LCL_FormItem" prop="LinkedVM.LCL" :label="$t('message.autotrans._Model_SpcAnalysis_LCL')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_SpcAnalysis_LCL')}), trigger: 'blur' }]" >
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.LCL" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_USL_FormItem" prop="LinkedVM.USL" :label="$t('message.autotrans._Model_SpcAnalysis_USL')">
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.USL" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_LSL_FormItem" prop="LinkedVM.LSL" :label="$t('message.autotrans._Model_SpcAnalysis_LSL')">
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.LSL" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Remark_FormItem" prop="LinkedVM.Remark" :label="$t('message.autotrans._Model_SpcAnalysis_Remark')">
          <el-input v-model="stateSpcAnalysis.vmModel.LinkedVM.Remark" clearable></el-input>
      </el-form-item>

      </el-col>
    </el-row>

    <div style="text-align:right;">
      <WtmButton @click="onSubmitSpcAnalysis"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

      <WtmButton @click="onCloseSpcAnalysis"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

    </div>

  </el-form>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageSpcManagementSpcAnalysisBatchEdit;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { spcanalysisApi } from '/@/api/spcmanagement/spcanalysis';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefSpcAnalysis = ref();
const stateSpcAnalysis = reactive({
    vmModel: {
	  LinkedVM:{
        Code: '',
        Desc: '',
        ChartType: undefined,
        ProductName: '',
        OpName: '',
        ChartName: '',
        DataName: '',
        DataTag: '',
        Remark: '',
      },
      Ids:[],
      
	},
    
});

// 取消
const onCloseSpcAnalysis = () => {
    closeDialog();
};

// 提交
const onSubmitSpcAnalysis = () => {
	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});

    formRefSpcAnalysis.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            spcanalysisApi().batchedit(stateSpcAnalysis.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error:any) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};


// 页面加载时
onMounted(() => {
    
    if (ci.attrs["wtmdata"]) {
		stateSpcAnalysis.vmModel.Ids = ci.attrs["wtmdata"];
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateSpcAnalysis.vmModel.Ids = useRouter().currentRoute.value.query.id as any;
	}

});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

